import type { Content } from '../../../types/document'
import type { StorageError } from '../../../services/storage/types'

export type DocumentTheme = 'light' | 'dark'

export interface DocumentStats {
  wordCount: number
  characterCount: number
}

export interface DocumentViewState {
  currentDocument: Content | null
  draftContent: string
  isDirty: boolean
  isLoading: boolean
  lastSavedAt: Date | null
  error: StorageError | null
  theme: DocumentTheme
  stats: DocumentStats
}

export interface DocumentStateActions {
  loadDocument: (id: string) => Promise<void>
  createNewDocument: (title?: string) => Promise<void>
  updateDraft: (content: string) => void
  updateTitle: (title: string) => void
  saveDocument: () => Promise<void>
  setTheme: (theme: DocumentTheme) => void
  resetError: () => void
}

export interface DocumentStateContextValue {
  state: DocumentViewState
  actions: DocumentStateActions
}
